/**
 * 
 */
package com.wrsr.examsys.teacher.service.impl;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import com.wrsr.examsys.base.dao.BaseDao;
import com.wrsr.examsys.base.service.impl.BaseServiceImpl;
import com.wrsr.examsys.domain.Teacher;
import com.wrsr.examsys.teacher.service.TeacherService;
import com.wrsr.examsys.util.MD5;

/**
 * @author <a href="mailto:2397431783@qq.com">wangruishun</a>
 * @version examsy1.0 2015年1月7日 下午9:53:34
 */
@Service("teacherService")
public class TeacherServiceImpl extends BaseServiceImpl<Teacher> implements TeacherService{

	/* (non-Javadoc)
	 * @see com.wrsr.examsys.teacher.service.TeacherService#emailIsValited(java.lang.String)
	 */
	@Override
	public boolean emailIsValited(String email) {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see com.wrsr.examsys.teacher.service.TeacherService#emailIsExist(java.lang.String)
	 */
	@Override
	public boolean emailIsExist(Teacher teacher) {
		String sql="from Teacher  where email=?";
		List<Teacher> tList=super.findEntityByHQL(sql,teacher.getEmail());
		if(tList==null||tList.size()==0){
			return false;
		}else{
			return true;
		}
	}

	/* (non-Javadoc)
	 * @see com.wrsr.examsys.teacher.service.TeacherService#codeIsRight(java.lang.String, javax.servlet.http.HttpServletRequest)
	 */
	@Override
	public boolean codeIsRight(String code, HttpServletRequest request) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean getTeacherByEmailAndPwd(Teacher teacher){
		String sql="from Teacher  where pwd=? and email=?";
		List<Teacher> tList=super.findEntityByHQL(sql, MD5.GetMD5Code(teacher.getPwd()),teacher.getEmail());
		if(tList==null||tList.size()==0){
			return false;
		}else{
			return true;
		}
	}

	/* (non-Javadoc)
	 * @see com.wrsr.examsys.base.service.impl.BaseServiceImpl#setDao(com.wrsr.examsys.base.dao.BaseDao)
	 */
	@SuppressWarnings("rawtypes")
	@Resource(name = "teacherDao")
	public void setDao(BaseDao dao) {
		super.setDao(dao);
	}

}
